﻿$('#detailsProviderPage').live('pageshow', function(event) {
	var id = getUrlVars()["id"];
	
     var theName = sessionStorage.getItem('theName');
	 var thePass = sessionStorage.getItem('thePass');
	 
	console.log(URLserviceProviders + '/getprovider.php?id='+id+'&name='+theName+'&thePass='+thePass);
	
	$.getJSON(URLserviceProviders + '/getprovider.php?id='+id+'&name='+theName+'&thePass='+thePass, displayProvider);
});

function displayProvider(data) {
	var provider = data.item;

	$('#ProvideriD').val(provider.id);
	$('#ProviderName').val(provider.name);
	$('#ProviderAdress').val(provider.adress);	
	$('#ProviderCity').val(provider.city);
	$('#ProviderTax1').val(provider.taxeno_1);	
	$('#ProviderTax2').val(provider.taxeno_2);	

}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
